home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 127 / PC Guia 127.iso / Software / Produtividade / OpenOffice.org 2.0.1 / openofficeorg4.cab / test_call.py < prev    next >
Text File  |  2005-11-19  |  3KB  |  132 lines

  1. import unittest
  2. from test import test_support
  3.  
  4. # The test cases here cover several paths through the function calling
  5. # code.  They depend on the METH_XXX flag that is used to define a C
  6. # function, which can't be verified from Python.  If the METH_XXX decl
  7. # for a C function changes, these tests may not cover the right paths.
  8.  
  9. class CFunctionCalls(unittest.TestCase):
  10.  
  11.     def test_varargs0(self):
  12.         self.assertRaises(TypeError, {}.has_key)
  13.  
  14.     def test_varargs1(self):
  15.         {}.has_key(0)
  16.  
  17.     def test_varargs2(self):
  18.         self.assertRaises(TypeError, {}.has_key, 0, 1)
  19.  
  20.     def test_varargs0_ext(self):
  21.         try:
  22.             {}.has_key(*())
  23.         except TypeError:
  24.             pass
  25.  
  26.     def test_varargs1_ext(self):
  27.         {}.has_key(*(0,))
  28.  
  29.     def test_varargs2_ext(self):
  30.         try:
  31.             {}.has_key(*(1, 2))
  32.         except TypeError:
  33.             pass
  34.         else:
  35.             raise RuntimeError
  36.  
  37.     def test_varargs0_kw(self):
  38.         self.assertRaises(TypeError, {}.has_key, x=2)
  39.  
  40.     def test_varargs1_kw(self):
  41.         self.assertRaises(TypeError, {}.has_key, x=2)
  42.  
  43.     def test_varargs2_kw(self):
  44.         self.assertRaises(TypeError, {}.has_key, x=2, y=2)
  45.  
  46.     def test_oldargs0_0(self):
  47.         {}.keys()
  48.  
  49.     def test_oldargs0_1(self):
  50.         self.assertRaises(TypeError, {}.keys, 0)
  51.  
  52.     def test_oldargs0_2(self):
  53.         self.assertRaises(TypeError, {}.keys, 0, 1)
  54.  
  55.     def test_oldargs0_0_ext(self):
  56.         {}.keys(*())
  57.  
  58.     def test_oldargs0_1_ext(self):
  59.         try:
  60.             {}.keys(*(0,))
  61.         except TypeError:
  62.             pass
  63.         else:
  64.             raise RuntimeError
  65.  
  66.     def test_oldargs0_2_ext(self):
  67.         try:
  68.             {}.keys(*(1, 2))
  69.         except TypeError:
  70.             pass
  71.         else:
  72.             raise RuntimeError
  73.  
  74.     def test_oldargs0_0_kw(self):
  75.         try:
  76.             {}.keys(x=2)
  77.         except TypeError:
  78.             pass
  79.         else:
  80.             raise RuntimeError
  81.  
  82.     def test_oldargs0_1_kw(self):
  83.         self.assertRaises(TypeError, {}.keys, x=2)
  84.  
  85.     def test_oldargs0_2_kw(self):
  86.         self.assertRaises(TypeError, {}.keys, x=2, y=2)
  87.  
  88.     def test_oldargs1_0(self):
  89.         self.assertRaises(TypeError, {}.update)
  90.  
  91.     def test_oldargs1_1(self):
  92.         {}.update({})
  93.  
  94.     def test_oldargs1_2(self):
  95.         self.assertRaises(TypeError, {}.update, {}, 1)
  96.  
  97.     def test_oldargs1_0_ext(self):
  98.         try:
  99.             {}.update(*())
  100.         except TypeError:
  101.             pass
  102.         else:
  103.             raise RuntimeError
  104.  
  105.     def test_oldargs1_1_ext(self):
  106.         {}.update(*({},))
  107.  
  108.     def test_oldargs1_2_ext(self):
  109.         try:
  110.             {}.update(*({}, 2))
  111.         except TypeError:
  112.             pass
  113.         else:
  114.             raise RuntimeError
  115.  
  116.     def test_oldargs1_0_kw(self):
  117.         self.assertRaises(TypeError, {}.update, x=2)
  118.  
  119.     def test_oldargs1_1_kw(self):
  120.         self.assertRaises(TypeError, {}.update, {}, x=2)
  121.  
  122.     def test_oldargs1_2_kw(self):
  123.         self.assertRaises(TypeError, {}.update, x=2, y=2)
  124.  
  125.  
  126. def test_main():
  127.     test_support.run_unittest(CFunctionCalls)
  128.  
  129.  
  130. if __name__ == "__main__":
  131.     test_main()
  132.